/**
 *******************************************************************************
 * @file      I2C.h
 * @version   V1.0.0    
 * @date      2013.05.20
 * @brief     I2C driver.	
 *
 * @author    - Adela 
 *            - Robert Zhang <armner@gmail.com>
 *            - 
 *
 */

#ifndef __I2C_H
#define __I2C_H

#define	EE_CMD_WRITE  (0)
#define	EE_CMD_READ   (1)

#define SCL_H         do{I2C_EE_GPIO->BSRRL = I2C_EE_SCL;}while(0)
#define SCL_L         do{I2C_EE_GPIO->BSRRH  = I2C_EE_SCL;}while(0)
#define SDA_H         do{I2C_EE_GPIO->BSRRL = I2C_EE_SDA;}while(0)
#define SDA_L         do{I2C_EE_GPIO->BSRRH  = I2C_EE_SDA;}while(0)
#define SCL_read      (I2C_EE_GPIO->IDR  & I2C_EE_SCL)
#define SDA_read      (I2C_EE_GPIO->IDR  & I2C_EE_SDA)
#define WP_H          do{I2C_EE_WP_GPIO->BSRRL = I2C_EE_WP;}while(0)
#define WP_L          do{I2C_EE_WP_GPIO->BSRRH = I2C_EE_WP;}while(0)

/* Exported functions ------------------------------------------------------- */
void I2C_Init(void);
char I2C_Write(char* pBuffer);
char I2C_Read(char* pBuffer);

void I2C_Start();
void I2C_Stop();
void I2C_ACK();
void I2C_NO_ACK();
short I2C_WAIT_ACK();
              
#endif /* __I2C_EE_H */


